<script>
import Config from '@/settings'
import { getToken } from '@/utils/auth'
import { requestGet } from '@/api/system/common'
export default {
  name: 'AuthLogin',
  created() {
    const width = document.body.clientWidth
    const service = this.$route.query.service
    if (service === undefined || service === null || service === '') {
      window.location.href = '/'
    } else if (width >= 1024) {
      // pc 端
      window.location.href = Config.casServer + Config.casServerLogin + '?service=' + service
    } else { // 移动端
      if (getToken()) {
        // 获取token
        requestGet('rest/api/auth/live-bos/cas/login', { type: Config.appType })
          .then((res) => {
            console.log(service)
            const { data } = res
            window.location.href = service + '?ticket=' + data.data + '&tag=true'
          }).catch(() => {
            window.location.href = '/auth/web/cas?type=' + Config.appType + '&redirect=' + service
          })
      } else {
        window.location.href = '/auth/web/cas?type=' + Config.appType + '&redirect=' + service
      }
    }
  }
}
</script>

<template>
  <div />
</template>

<style scoped>

</style>
